{% extends 'layout.html'%}

{% block content%}
{%for content in contents %}
<div class="article-list">
    <h4 class="text-center article-title">{{content.title}}</h4>
    <p class="text-center">
        <span>作者：</span>
        <a href="#">{{content.user.username}}</a>&nbsp;
        <span>时间：</span>
        <a href="#">{{content.addTime | date('Y-m-d H:i:s',-8*60)}}</a>&nbsp;
        <span>阅读：</span>
        <a href="#">{{content.views}}</a>&nbsp;
        <span>评论：</span>
        <a href="#">{{content.comments.length}}</a>
    </p>
    <p>{{content.description}}</p>
    <a href="/view?contentid={{content.id}}" type='button' class="btn btn-warning">阅读全文</a>
</div>
{% endfor %}
<nav aria-label="Page navigation">
    <ul class="pagination">
        <li>
            {% if page<=1 %}
            <a href="javascript:;" aria-label="Previous">
                <span aria-hidden="true">没有上一页了</span>
            </a>
            {% else %}
            <a href="/?category={{category}}&page={{page-1}}" aria-label="Previous">
                <span aria-hidden="true">&laquo;</span>
            </a>
            {% endif %}

        </li>
        {% if pages>0 %}
        <li><a href="#">{{page}}/{{pages}}</a></li>
        {% endif %}

        <li>
            {% if page>= pages %}
            <a href="javascript:;" aria-label="Next">
                <span aria-hidden="true">没有下一页</span>
            </a>
            {% else %}
            <a href="/?category={{category}}&page={{page+1}}" aria-label="Next">
                <span aria-hidden="true">&raquo;</span>
            </a>
            {% endif %}
        </li>
    </ul>
</nav>
{%endblock%}